package com.trover.myapplication.core.http

import com.trover.myapplication.core.util.PrefUtils
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response

class AddCookiesInterceptor : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val builder: Request.Builder = chain.request().newBuilder()
        val cookies: MutableSet<String>? = PrefUtils.getHashSet(RetrofitConstants.COOKIE)
        if (cookies != null) {
            for (cookie in cookies) {
//                builder.addHeader("Set-Cookie", cookie)
                builder.addHeader("Cookie", cookie)
            }
        }
        return chain.proceed(builder.build())
    }
}